<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>自定义遍历对象</title>
    </head>
    <body>
        <script>
            //1.声明一个对象
            const _class = {
                name:"终极一班",
                content:[
                    "汪大东",
                    "辜战",
                    "花灵龙"
                ],
                [Symbol.iterator](){
                    //设置索引
                    let index = 0;
                    return {
                        next:()=>{
                            if(index < this.content.length){
                                const result = { value: this.content[index], done: false };
                                index ++;
                                return result;
                            }else{
                                return { value: undefined, done: true};
                            };
                        }
                    };
                }
            };
            //遍历这个对象
           for(let i of _class){
               console.log(i);
           }

           let iterator = _class[Symbol.iterator]();
           console.log(iterator.next());
            console.log(iterator.next());
             console.log(iterator.next());
              console.log(iterator.next());
        </script>
    </body>
</html>